<?php
include('../../__global.php');
class aj_getFeedComment extends ml_controller 
{
    private $_rid;
    private $oAccount;
    public function initParam(){
        $this->_rid=$this->input('rid','g');
        $this->oAccount=new ml_model_dbUserAccount();    
    }
    public function checkParam(){
        $this->check_referer();
        if(!ml_tool_resid::is_resid($this->_rid))
            $this->api_output(ML_RCODE_PARAM);
    }
    
    
    public function main(){
        $oComment=new ml_model_dbComment();
        $oUserfeed=new ml_model_dbUserfeed();
        
        $oComment->getCountsByRid($this->_rid);
        $data['totalNum']=$oComment->get_data();
        $data['totalNum']=$data['totalNum']['num'];
        if($data['totalNum']=='0'){
            $this->api_output(ML_RCODE_SUCC,'');
        }
        
        $rs=$oComment->getCommentsByRid($this->_rid,0,4);
        if(!$rs)
            $this->api_output(ML_RCODE_BUSY);
                
        $comments=$oComment->get_data();
        $htmlArr=ml_tool_commentOutput::parseCommentTpl($comments);
        
        
        
        $data['item']='';
        foreach ($htmlArr as $val){
            $data['item'].=$val;
            
        }
        
        $type=$oUserfeed->getTypeByRid($this->_rid);

        
        $typeArr=array(
            ML_FEED_TYPE_PUB_DOTEY,
            ML_FEED_TYPE_PUB_PIC ,
            ML_FEED_TYPE_ATTITUDE,
            ML_FEED_TYPE_REPOST_PIC,
            ML_FEED_TYPE_REPOST_COLLECTION 
        );
        if(in_array($type['Type'],$typeArr)){
            $data['type']='1';
        }else{
            $data['type']='2';
        }
        $this->api_output(ML_RCODE_SUCC,$data);
    }
}
new aj_getFeedComment();